class Solution:
    def numDistinct(self, s: str, t: str) -> int:
        dp = [[0 for _ in range(len(t) + 1)] for _ in range(len(s) + 1)]
        dp[0][0] = 1
        for i in range(len(s)):
            dp[i + 1][0] = 1
            for j in range(len(t)):
                if j > i:
                    break
                if s[i] == t[j]:
                    dp[i + 1][j + 1] = dp[i][j + 1] + dp[i][j]
                else:
                    dp[i + 1][j + 1] = dp[i][j + 1]

        return dp[-1][-1]
